<!-- 我的钱包 -->
<template>
	<view>
		<view class="bg-red"></view>
		
		<view class="px-3">
			<view class="money-block">
				<view class="bt-block flex justify-around align-center padding-tb-lg">
					<view>
						<view class="font-12 font-gray mb-1">我的余额</view>
						<view class="money-text" ><text class="font-1">¥ </text> {{obj.balance}} </view>
					</view>
					<view class="middle-line"> </view>
					<view>
						<view class="font-12 font-gray mb-1">我的红包(项目奖金)</view>
						<view class="money-text"><text class="font-1">¥ </text> {{obj.interest}}</view>
					</view>
				</view>
			</view>
			<view class="info font-12 font-gray my-3">
				说明：提现仅限提现项目奖金，可直接提现
			</view>
			<view class="bt-block my-3">
				<bg-cell2 :border="false" label="到账银行卡">
					<template slot="value">
						<view>{{obj.bankName}}({{obj.bankCardNo}})</view>
					</template>
				</bg-cell2>
			</view>
			<view class="bt-block my-3 px24py30">
				<view class="font-13">
					提现金额
				</view>
					
				<view class="my-2">
					<u-input v-model="cash" border="none" fontSize="26" color="#000000">
						<u--text
							text="¥"
							slot="prefix"
							margin="0 3px 0 0"
							type="tips"
						></u--text>
					</u-input>
				</view>
				
				<view class="bt-line-1"></view>
				<view class="info font-12 font-gray margin-top-lg">
					说明：提现后预计7个工作日内到账
				</view>
			</view>
			<view class="mt-4">
				<bg-btn @click="saveData">我要提现</bg-btn>
			</view>
		</view>
	</view>
</template>

<script>
	import {myWallet, cashWallet} from "@/api/mine.js"
	export default {
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url:"/pages/mine/history/history"
			})
		},
		data() {
			return {
				cash:0,
				obj:{},
			}
		},
		mounted() {
			this.getData()
		},
		methods: {
			getData(){
				myWallet().then(res=>{
					this.obj = res.data
				})
			},
			saveData(){
				if(!uni.$u.test.number(this.cash)){
					this.$modal.msg("请输入正确的提现金额")
					return false
				}
				if(this.cash<=0){
					this.$modal.msg("请输入正确的提现金额")
					return false
				}
				if(this.cash > this.obj.balance){
					this.$modal.msg("请输入正确的提现金额")
					return false
				}
				cashWallet({
					"amount": this.cash,
					  "bankName": this.obj.bankName,
					  "bankCardNo": this.obj.bankCardNo
				}).then(res=>{
					this.cash = 0
					this.getData()
					this.$modal.msgSuccess("提现申请成功")
				})
			},
		}
	}
</script>

<style scoped> 
	.bg-red {
		width: 100%;
		height: 236rpx;
		background-color: #ee3636;
	}
	.money-block {
		box-sizing: border-box;
		margin-top: -128rpx;
	}
	.middle-line {
		width: 1rpx;
		height: 60rpx;
		background-color: #ededed;
	}
	.money-text {
		font-size: 52rpx;
	}
</style>
